<?php
class PortalController extends Controller
{
    public $layoutData = null ;

    public function actionTest()
    {
        $result = new stdClass();
        $result->hasLogin = false;
        $this->layoutData = $result;
        if($result->hasLogin)
        {
            $this->render('test', array(
                'ret' => $result,
            ));
        }else
        {
            $this->render('test', array(
                'ret' => $result,
            ));
        }
    }


    public function actionIndex()
    {
        $result = new stdClass();
        $result->hasLogin = false;
        $this->layoutData = $result;
        if($result->hasLogin)
        {
            $this->render('index', array(
                'ret' => $result,
            ));
        }else
        {
            $this->render('login', array(
                'ret' => $result,
            ));
        }
    }

    public function actionDoLogin()
    {
        $result = new stdClass();
        $result->hasLogin = false;
        $name = $_POST["name"];
        $pwd = $_POST["password"];
        $remember = false;
        if(in_array("rb-pwd",$_POST) && $_POST["rb-pwd"]=="on")
        {
            $remember = true;
        }
        if($name=="admin" && $pwd=="admin")
        {
            $result->hasLogin = true;
        }

        $this->layoutData = $result;

        if($result->hasLogin)
        {
            $this->render('index', array(
                'ret' => $result,
            ));
        }else
        {
            $this->render('login', array(
                'ret' => $result,
            ));
        }
    }
}
